#ifndef DDAPOSTPLAYER_H
#define DDAPOSTPLAYER_H

#include <QWidget>
#include <QDialog>
#include <qtcore/qthread.h>
#include <qtcore/QObject>
#include <qtcore/QMutex>
#include <QtCore/QSize>
// #include <QtCore/qtimer.h>
#include "GraphTools.h"
#include "FrameMaker.h"
#include "BaseConfigs.h"
#include "FrameProducerConsumer.h"
// #include <Gui/View3DInventor.h>
// #include <Gui/View3DInventorViewer.h>


#include <Inventor/Qt/viewers/SoQtViewer.h>

class View3DInventorViewer;

namespace Ui {
class DDAPostPlayer;
}

namespace DDAGui{
//#define DEBUGPOSTPLAYER
class DDAPostPlayer : public QDialog
{
    Q_OBJECT
public:
    explicit DDAPostPlayer(QWidget *parent = 0);
    ~DDAPostPlayer();
    
public Q_SLOTS:
    void frameIndexChanged(int frameIndex);

    void playBtnPressed();
    void openBtnPressed();
    void stopBtnPressed();

private Q_SLOTS:
    void spinBoxValueChanged(int value);
    void sliderValueChanged(int value);
	void scaleValueChanged(double scale);
	void radioButtonAccumulatedDisplacementClicked();
	void radioButtonRealTimeDisplacementClicked();
	void radioButtonRealXDisplacementClicked();
	void radioButtonRealYDisplacementClicked();
    void radioButtonStressClicked();

Q_SIGNALS:
    void startPlay();
    void play1Frame(int frameIndex);
    void stopPlay();
    void pausePlay();

public:
    void setRootSceneNode(SoSeparator* root){_rootScene = root;}
    void setSoQtViewer(SoQtViewer* viewer){_soQtViewer = viewer;/*_soQtViewer->setAntialiasing(true,2);*/}

private:
    void initPlay(int framesNum);
    void initFrameRealtedConnection();
    void disconnectFrameRealtedConnection();
    void initUIConnection();
    void play();
    void handleDataUnValid();
	void handleDataFileErrorUnValid(char* msg);

protected:
    bool eventFilter(QObject* target , QEvent* event);

private:
    DDAGui::FrameProducer* _producer;
    DDAGui::FrameConsumer* _consumer;
     SoSeparator* _rootScene;
    SoQtViewer* _soQtViewer;

    QThread* _produceThread;
    QThread* _consumeThread;
    Ui::DDAPostPlayer *ui;

};

}
#endif // DDAPOSTPLAYER_H
